#include <QtGui>

#include "glwidget.h"
#include "window.h"
#include <QThread>

Window::Window()
{
    glWidget = new GLWidget;
	jeu = new Jeu ;
	
	connect(jeu, SIGNAL(modePieceOn(bool)), glWidget, SLOT(pieceSelectionOn (bool)));
	connect(jeu, SIGNAL(modePieceOff()), glWidget, SLOT(pieceSelectionOff ()));
	connect(jeu, SIGNAL(modePositionOn(const std::list<Position> &)), glWidget, SLOT(positionSelectionOn (const std::list<Position> &)));
	connect(jeu, SIGNAL(modePositionOff()), glWidget, SLOT(positionSelectionOff ()));
	connect(jeu, SIGNAL(updatePieces(std::list<Piece*>)), glWidget, SLOT(setPieces(std::list<Piece*>))) ;
	connect(jeu, SIGNAL(tourneScene()), glWidget, SLOT(toggleScene())) ;
	
	connect(glWidget, SIGNAL(pieceSelected(PieceGL *)), jeu, SLOT(setSelectedPiece (PieceGL *)));
	connect(glWidget, SIGNAL(positionSelected(Position *)), jeu, SLOT(setSelectedPosition (Position *)));	
	
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(glWidget);
    setLayout(mainLayout);

    setWindowTitle(tr("ChessMaster"));
	
	jeu->start() ;
}

Window::~Window(){
}